package edu.software.cakehomework.dao;

import edu.software.cakehomework.entity.Menu;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;

public interface MenuRepository extends JpaRepository<Menu, Integer> {
    Page<Menu> findByCategory(String category, Pageable pageable);

    @Query("SELECT m FROM Menu m WHERE m.name LIKE %:keyword% OR m.description LIKE %:keyword%")
    Page<Menu> searchByKeyword(String keyword, Pageable pageable);

    List<Menu> findByIsAvailableTrue();

    @Query("SELECT DISTINCT m.category FROM Menu m")
    List<String> findAllCategories();
}